<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>isDeepFrozen</title>
</head>

<body>
    <div>打开浏览器控制台查看结果</div>
    <script>
        const isDeepFrozen = obj =>
            Object.isFrozen(obj) &&
            Object.keys(obj).every(
                val => typeof val !== 'object' || isDeepFrozen(obj[val])
            );
        const x = Object.freeze({ a: 1 });
        const y = Object.freeze({ b: { c: 2 } });
        console.log(isDeepFrozen(x)); // true
        console.log(isDeepFrozen(y)); // false
    </script>
</body>

</html>